package com.wl.eb.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wl.eb.mapper.EbUserMapper;
import com.wl.eb.module.EbUser;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

@Service
public class LoginService {
    @Resource
    private EbUserMapper ebUserMapper;
    public EbUser login(EbUser ebUser){
        List<EbUser> ebUserList=ebUserMapper.selectList(new QueryWrapper<EbUser>()
        .eq("Eu_User_Name",ebUser.getEuUserName())
        .eq("Eu_Password",ebUser.getEuPassword()));
        if(ebUserList.size()==0){
            throw new RuntimeException("登录失败");
        }
        return ebUserList.get(0);
    }
    public boolean register(EbUser ebUser){
        String ebuserId= UUID.randomUUID().toString().replace("-","").substring(0,10);
        ebUser.setEuUserId(ebuserId);
        ebUser.setEuStatus(1);
        ebUser.setEuSex("T");
        int result=ebUserMapper.insert(ebUser);
        return result>0?true:false;
    }
}
